import pytest
from appium import webdriver
from appium.options.android import UiAutomator2Options
from appium.webdriver.webdriver import WebDriver

from utils.ymal_reader import YamlReader


@pytest.fixture(scope="session")
def init_driver() -> WebDriver:
    desired_caps = YamlReader.get_env_config()["desired_caps"]
    print("Desired Capabilities: ", desired_caps)
    driver = webdriver.Remote(YamlReader.get_env_config()["url"],
                                  options=UiAutomator2Options().load_capabilities(desired_caps))
    yield driver
    print("close app")
    driver.quit()